# 超级管理员

from django.contrib import admin
from disease.models import DiseaseDirectionModel,DiseaseCategoryModel,DiseaseMessageModel,DiseaseModel
# Register your models here.

# 这个是让疾病方向表和疾病分类表关联起来，这样在疾病方向表中可以直接添加疾病分类表的数据
class DiseaseCategoryInline(admin.TabularInline):
    model = DiseaseCategoryModel
    fields = ['id','name','orders']

class DiseaseDirectionAdmin(admin.ModelAdmin):
    list_display = ['id', 'name']
    inlines = [DiseaseCategoryInline]

# 注册疾病分类表
admin.site.register(DiseaseDirectionModel,DiseaseDirectionAdmin)

class DiseaseCategoryAdmin(admin.ModelAdmin):
    list_display = ['id', 'name','direction']

admin.site.register(DiseaseCategoryModel,DiseaseCategoryAdmin)

class DiseaseAdmin(admin.ModelAdmin):
    list_display = ['id', 'name','category']

admin.site.register(DiseaseModel,DiseaseAdmin)

class DiseaseMessageAdmin(admin.ModelAdmin):
    list_display = ['id', 'name','direction','category','disease','author','message_cover_small']
    ordering = ['id']
    search_fields = ['name']
    list_filter = ['direction__name','category__name','disease__name']

admin.site.register(DiseaseMessageModel,DiseaseMessageAdmin)